# 15.2 折线图
import matplotlib.pyplot as plt

square = [1, 4, 9, 16, 25]
input_values = [1, 2, 3, 4, 5]

# 15.2.3 使用内置样式（预定义样式）
# 设置好的背景色、网格线、线条粗细、字体、字号

# 1、查看可用的样式：
# >>> import matplotlib.pyplot as plt
# >>> plt.style.available
# ['Solarize_Light2', '_classic_test_patch', '_mpl-gallery',
# '_mpl-gallery-nogrid', 'bmh', 'classic', 'dark_background',
# 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn',
# 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark',
# 'seaborn-dark-palette', 'seaborn-darkgrid', 'seaborn-deep',
# 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel',
# 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white',
# 'seaborn-whitegrid', 'tableau-colorblind10']

# 样式的设置要在创建图表之前
plt.style.use('seaborn')

fig, ax = plt.subplots()
ax.plot(input_values, square, linewidth=3)

# 设置标题和坐标轴
ax.set_title('平方数', fontsize=24)
ax.set_xlabel('值', fontsize=14)
ax.set_ylabel('值的平方', fontsize=14)

# 设置刻度标记的大小
# axis的值可以是"x", "y", "both"
ax.tick_params(axis='both', labelsize=14)
# 更多 https://blog.csdn.net/helunqu2017/article/details/78736554

# tick_params语法
# Axes.tick_params(axis='both', **kwargs)

# 参数:
# axis : {‘x’, ‘y’, ‘both’} Axis on which to operate; default is ‘both’.
# reset : bool If True, set all parameters to defaults before processing other keyword arguments. Default is False.
# which : {‘major’, ‘minor’, ‘both’} Default is ‘major’; apply arguments to which ticks.
# direction : {‘in’, ‘out’, ‘inout’} Puts ticks inside the axes, outside the axes, or both.
# length : float Tick length in points.
# width : float Tick width in points.
# color : color Tick color; accepts any mpl color spec.
# pad : float Distance in points between tick and label.
# labelsize : float or str Tick label font size in points or as a string (e.g., ‘large’).
# labelcolor : color Tick label color; mpl color spec.
# colors : color Changes the tick color and the label color to the same value: mpl color spec.
# zorder : float Tick and label zorder.
# bottom, top, left, right : bool or {‘on’, ‘off’} controls whether to draw the respective ticks.
# labelbottom, labeltop, labelleft, labelright : bool or {‘on’, ‘off’} controls whether to draw the respective tick labels.
# labelrotation : float Tick label rotation

# 设置中文字体，否则乱码
plt.rcParams['font.sans-serif'] = ['SimHei']
# 显示负号
plt.rcParams['axes.unicode_minus'] = False

plt.show()
